package com.software.practicecenter.service;

import com.software.practicecenter.entity.KnowledgePoint;
import com.software.practicecenter.repository.KnowledgePointRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collection;
import java.util.List;
import java.util.Optional;

/**
 * @Author xiaoliao
 * @Date 2023/5/31 14:38
 */
@Transactional
@Service
public class KnowledgePointService {

    @Autowired
    private KnowledgePointRepository knowledgePointRepository;
    public KnowledgePoint findKnowledgePointById(String id) {
        Optional<KnowledgePoint> optional = knowledgePointRepository.findById(id);
        KnowledgePoint knowledgePoint = null;
        if (optional.isPresent()) {
            knowledgePoint = optional.get();
            return knowledgePoint;
        }
        else {
            System.out.println("id 不存在");
            return knowledgePoint;
        }
    }

    public List<KnowledgePoint> findByIdIn(Collection<String> ids) {
        return knowledgePointRepository.findByIdIn(ids);
    }
}
